//------------------------------------------------------------------------------
// File: CudaFilterKernel.h
// 
// Author: Ren Yifei, Lin Ziya
//
// Contact: yfren@cs.hku.hk, zlin@cs.hku.hk
//
// Desc: Cuda Retinex Filter, please refer to the paper below:
//
// "Recursive Implementation of the gaussian filter.",
// Ian T. Young , Lucas J. Van Vliet, Signal Processing 44, Elsevier 1995.
//
//------------------------------------------------------------------------------

#ifndef _CUDA_KERNEL_H_
#define _CUDA_KERNEL_H_

#include <cmath>
#include <cuda.h>
#include <cutil.h>

#pragma warning(disable: 4244) // double to float convertion, ignore

typedef unsigned char BYTE;
typedef unsigned int uint32;

struct GaussianCoef
{
	int    N;
	float  sigma;
	float  B;
	float  b[4];
};

bool CUDAInit(int width, int height);

void CUDARelease();

bool CUDABeginFiltering(BYTE* pImageIn, 
						long dataLength, 
						float minScale, 
						float maxScale, 
						int scaleNum);

bool CUDAEndFiltering(BYTE* pImageOut);

void FilterWrapper(int maxRow, int maxCol);

uint32 PackARGB_CPU(float a, float r, float g, float b);

uint32 GetRGB_CPU(uint32 rbg, uint32 channel);

#endif